import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import axios from 'axios'
import 'element-plus/dist/index.css'
import ElementPlus from 'element-plus'
import { MiscCfgsRecord } from './ts/MiscCfgs'
import {router} from './router'
// import {JsonViewer} from 'vue3-json-viewer'
import JsonViewer from 'vue3-json-viewer'
import "vue3-json-viewer/dist/index.css"
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'vxe-table/lib/style.css'

// Import vxe-table
import VXETable from 'vxe-table'
import zhCn from 'element-plus/es/locale/lang/zh-cn.mjs'
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'

//axios.defaults.baseURL = "http://192.168.68.189:8005"
// 配置请求头
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
// 启用认证防止session失效
// axios.defaults.withCredentials = true;

const app = createApp(App)

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

app.config.globalProperties.$axios = axios
app.provide('http', axios)

app.provide('misc_cfgs', loadMiscCfgs())
dayjs.locale('zh-cn')
app.use(ElementPlus, { locale: zhCn })
app.use(router)
app.use(JsonViewer)

// Register VXETable components
app.use(VXETable as any)

// Configure and register vxe-table
app.use(VXETable, {
  table: {
    border: true,
    stripe: true,
    showOverflow: true,
    align: 'center',
    rowConfig: {
      isHover: true
    }
  }
})

app.mount('#app')

function loadMiscCfgs() {
    return {
        "logConsoleShowVh": 83
    } as MiscCfgsRecord
}
